/*
 * 项 目 名  :   chopstickshealth
 * 作      者  :  Li Jun
 * 类      名  :  VerifyCodeTimerUtils.java
 * 包      名  :  com.dw.chopstickshealth.utils.VerifyCodeTimerUtils
 * 当前修改时间 :  2019年04月19日 14:00:31
 * 上次修改时间 :  2019年04月08日 08:41:28
 * Copyright (c) 2019  重庆中联信息产业有限责任公司 http://www.zlsoft.com
 */

package com.zlsoft.web.utils;

/**
 * Created by Administrator on 2016/10/14.
 */

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * Created by Jackie on 2015/11/30.
 */
public class VerifyCodeTimerUtils extends CountDownTimer {
    private TextView mTextView;
    private VerifyCodeTimerUtils verifyCodeTimerUtils;
    /** callBack */
    private FinishCallback finishCallback;


    /**
     * @param
     * @param millisInFuture    The number of millis in the future from the call
     *                          to {@link #start()} until the countdown is done and {@link #onFinish()}
     *                          is called.
     * @param countDownInterval The interval along the way to receiver
     *                          {@link #onTick(long)} callbacks.
     */
    public VerifyCodeTimerUtils( long millisInFuture, long countDownInterval, FinishCallback finishCallback) {
        super(millisInFuture, countDownInterval);
//        this.mTextView = textView;
        this.finishCallback = finishCallback;

    }

    @Override
    public void onTick(long millisUntilFinished) {
//        mTextView.setClickable(false); //设置不可点击
//        long time = (millisUntilFinished + 100) / 1000 >= 1 ? (millisUntilFinished + 100) / 1000 : 1;
//        if (11>(millisUntilFinished + 100) / 1000){
//            mTextView.setText(time + "秒页面关闭");  //设置倒计时时间
//        }else {
//            mTextView.setText("");//时间大于10s时不显示
//        }
//        mTextView.setTextColor(Color.parseColor("#A8A8A8"));
//        mTextView.setBackgroundResource(R.drawable.shape_btn_round_hollow_gary); //设置按钮为灰色，这时是不能点击的
    }

    @Override
    public void onFinish() {
            finishCallback.mfinish();

//        mTextView.setText("重新获取");
//        mTextView.setClickable(true);//重新获得点击
//        mTextView.setTextColor(Color.parseColor("#4BC6C4"));
//        mTextView.setBackgroundResource(R.drawable.shape_btn_round_hollow_accent);  //还原背景色
    }



    public interface FinishCallback {
        void mfinish();
    }


}